﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PublicMessage>" %>
<%@import Namespace="ViewRes" %>
<div class="publicMessage">
    <div>
        <table cellspacing="0" cellpadding="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <%
                            if (Model.User is Lecturer)
                            {%>
                        <img src="<%:Url.Content("~/Content/Icons/lecturer.png")%>" class="avalogo" />
                        <%
                            }%>
                        <%
                            if (Model.User is SystemManager)
                            {%>
                        <img src="<%:Url.Content("~/Content/Icons/sysmanager.png")%>" class="avalogo" />
                        <%
                            }%>
                        <%
                            if (Model.User is Administrator)
                            {%>
                        <img src="<%:Url.Content("~/Content/Icons/admin.jpg")%>" class="avalogo" />
                        <%
                            }%>
                    </td>
                    <td>
                        <div>
                            <div class="UserName">
                                <%:Model.User.FullName%></div>
                            <div class="Message">
                                <%:Model.Message%>
                            </div>
                            <%
                            if (Model.AttachedFilePath != null)
                            {%>
                            <div class="File">
                                <%
                                string relativeFilePath = Model.AttachedFilePath;%>
                                <a href="<%:Url.Content(relativeFilePath)%>">
                                    <img src="<%:Url.Content("~/Content/Icons/attachment.png")%>" />
                                    <span style="vertical-align: top;">
                                        <%:
                                    Model.AttachedFilePath.Substring(Model.AttachedFilePath.LastIndexOf(@"\") + 1)%></span></a>
                            </div>
                            <%
                            }%>
                        </div>
                        <div>
                            <small><span class="PubDate">
                                <%:Model.PubDate%></span></small>
                            <%
                            if (Model.User == (ViewData["LoggedUser"] as User))
                            {%>
                            <span><a href="<%:Url.RouteUrl("Default",
                                                               new
                                                                   {
                                                                       controller = "PublicMessages",
                                                                       action = "Delete",
                                                                       id = Model.PublicMessageId
                                                                   })%>"
                                class="deleteLink">
                                <img class="mediumIcon" src="<%:Url.Content("~/Content/Icons/delete.png")%>" title = "<%:SharedStrings.Delete%>" />
                            </a></span>
                            <%
                            }%>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
